<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"eryangz.gitee.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"mac"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="本文档简单介绍了odoo前端组件开发，文档内容来源于资深odoo工程师李黎">
<meta property="og:type" content="article">
<meta property="og:title" content="odoo前端组件开发">
<meta property="og:url" content="https://eryangz.gitee.io/20200618/odoo%E5%89%8D%E7%AB%AF%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91/index.html">
<meta property="og:site_name" content="二扬">
<meta property="og:description" content="本文档简单介绍了odoo前端组件开发，文档内容来源于资深odoo工程师李黎">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-18T12:20:33.000Z">
<meta property="article:modified_time" content="2023-05-20T09:05:32.943Z">
<meta property="article:author" content="二扬">
<meta property="article:tag" content="js">
<meta property="article:tag" content="odoo前端">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://eryangz.gitee.io/20200618/odoo%E5%89%8D%E7%AB%AF%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>odoo前端组件开发 | 二扬</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">二扬</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">blog</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://eryangz.gitee.io/20200618/odoo%E5%89%8D%E7%AB%AF%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="二扬">
      <meta itemprop="description" content="念念不忘, 必有回响">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="二扬">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          odoo前端组件开发
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-06-18 20:20:33" itemprop="dateCreated datePublished" datetime="2020-06-18T20:20:33+08:00">2020-06-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-05-20 17:05:32" itemprop="dateModified" datetime="2023-05-20T17:05:32+08:00">2023-05-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/odoo/" itemprop="url" rel="index"><span itemprop="name">odoo</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>5 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>本文档简单介绍了odoo前端组件开发，文档内容来源于资深odoo工程师<strong>李黎</strong><span id="more"></span></p>
<h1 id="自定义ODOO-JS组件（初级）"><a href="#自定义ODOO-JS组件（初级）" class="headerlink" title="自定义ODOO JS组件（初级）"></a>自定义ODOO JS组件（初级）</h1><p>odoo让页面开发变得快捷，也限制了页面的多样性</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;abs-br m-6 flex gap-2&quot;</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">button</span> @<span class="attr">click</span>=<span class="string">&quot;$slidev.nav.openInEditor()&quot;</span> <span class="attr">title</span>=<span class="string">&quot;Open in Editor&quot;</span> <span class="attr">class</span>=<span class="string">&quot;text-xl icon-btn opacity-50 !border-none !hover:text-white&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">carbon:edit</span> /&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;https://github.com/slidevjs/slidev&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;GitHub&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">class</span>=<span class="string">&quot;text-xl icon-btn opacity-50 !border-none !hover:text-white&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">carbon-logo-github</span> /&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">The last comment block of each slide will be treated as slide notes. It will be visible and editable in Presenter Mode along with the slide. [Read more in the docs](https://sli.dev/guide/syntax.html#notes)</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br></pre></td></tr></table></figure>
<hr>
<h1 id="什么是odoo-js组件？"><a href="#什么是odoo-js组件？" class="headerlink" title="什么是odoo js组件？"></a>什么是odoo js组件？</h1><ul>
<li>odoo整个页面是由组件构件，组件分上下级，从最顶级web_client到最底层的字段组件（<code>FieldFloat</code>、<code>FieldMonetary</code>）<br>`</li>
<li>一个组件可能是整个页面、也可能是某个字段、也可能是页面上某个按钮、某个元素</li>
</ul>
<hr>
<h1 id="组件的分类："><a href="#组件的分类：" class="headerlink" title="组件的分类："></a>组件的分类：</h1><br>
（我分的🙂）
<br>


<ul>
<li>视图组件</li>
</ul>
<p><code>tree</code>、<code>form</code>、<code>js_class</code></p>
<ul>
<li>字段组件</li>
</ul>
<p><code>&lt;field name=&quot;product_id&quot; widget=&quot;many2one&quot;/&gt;</code></p>
<ul>
<li>非字段组件</li>
</ul>
<p><code> &lt;widget name=&quot;web_ribbon&quot;/&gt;</code></p>
<ul>
<li>动作组件  </li>
</ul>
<hr>
<h1 id="动作组件"><a href="#动作组件" class="headerlink" title="动作组件"></a>动作组件</h1><ul>
<li>为什么分享这一个而不是其他组件？</li>
<li>什么时候需要这个？</li>
</ul>
<hr>
<h1 id="怎么用？"><a href="#怎么用？" class="headerlink" title="怎么用？"></a>怎么用？</h1><ul>
<li>方式1：</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Sale</span>(<span class="params">models.Model</span>):</span></span><br><span class="line">    _name = <span class="string">&#x27;sale.order&#x27;</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">action_button</span>(<span class="params">self</span>):</span></span><br><span class="line">        <span class="keyword">return</span> &#123;</span><br><span class="line">            <span class="string">&#x27;type&#x27;</span>: <span class="string">&#x27;ir.actions.client&#x27;</span>,</span><br><span class="line">            <span class="string">&#x27;name&#x27;</span>: <span class="string">&#x27;销售报表&#x27;</span>,</span><br><span class="line">            <span class="string">&#x27;tag&#x27;</span>: <span class="string">&#x27;my_sale_report&#x27;</span>,</span><br><span class="line">        &#125;   </span><br></pre></td></tr></table></figure>

<ul>
<li>方式2<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- file_a.xml --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">record</span> <span class="attr">id</span>=<span class="string">&quot;action1&quot;</span> <span class="attr">model</span>=<span class="string">&quot;ir.actions.client&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">&quot;name&quot;</span>&gt;</span>销售报表<span class="tag">&lt;/<span class="name">field</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">&quot;tag&quot;</span>&gt;</span>my_sale_report<span class="tag">&lt;/<span class="name">field</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">record</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!-- file_b.xml --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">menuitem</span> <span class="attr">id</span>=<span class="string">&quot;menu1&quot;</span> <span class="attr">parent</span>=<span class="string">&quot;parent_menu&quot;</span> <span class="attr">action</span>=<span class="string">&quot;action1&quot;</span> <span class="attr">string</span>=<span class="string">&quot;销售报表&quot;</span>/&gt;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
</ul>
<hr>
<h1 id="一些系统已有的客户端动作"><a href="#一些系统已有的客户端动作" class="headerlink" title="一些系统已有的客户端动作"></a>一些系统已有的客户端动作</h1><ul>
<li><code>display_notification</code></li>
<li><code>reload</code></li>
</ul>
<hr>
<h1 id="怎么写？"><a href="#怎么写？" class="headerlink" title="怎么写？"></a>怎么写？</h1><h3 id="需要一些基础的JS知识"><a href="#需要一些基础的JS知识" class="headerlink" title="需要一些基础的JS知识"></a>需要一些基础的JS知识</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a = <span class="number">1</span>;</span><br><span class="line"><span class="keyword">var</span> b = <span class="function"><span class="keyword">function</span>(<span class="params">arg1, arg2</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">return</span> arg1 + arg2</span><br><span class="line">&#125;;</span><br><span class="line"><span class="keyword">var</span> c = &#123;</span><br><span class="line">    <span class="string">&#x27;var_a&#x27;</span>: a,</span><br><span class="line">    <span class="string">&#x27;var_b&#x27;</span>: b,</span><br><span class="line">    <span class="string">&#x27;var_c&#x27;</span>: <span class="number">3</span>, </span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">console</span>.log(c[<span class="string">&#x27;var_b&#x27;</span>](<span class="number">1</span>, <span class="number">2</span>))</span><br></pre></td></tr></table></figure>


<hr>
<h1 id="一些需要知道的点"><a href="#一些需要知道的点" class="headerlink" title="一些需要知道的点"></a>一些需要知道的点</h1><hr>
<h3 id="JS的模块（1）-为什么需要模块？"><a href="#JS的模块（1）-为什么需要模块？" class="headerlink" title="JS的模块（1） - 为什么需要模块？"></a>JS的模块（1） - 为什么需要模块？</h3><ul>
<li>可维护</li>
<li>命名空间 </li>
<li>可复用</li>
<li>依赖顺序<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;/web/xx/1.js&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;/web/xx/2.js&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;/web/xx/3.js&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;/web/xx/4.js&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line">    ...</span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
</ul>
<hr>
<h3 id="JS的模块（2）-模块怎么写？"><a href="#JS的模块（2）-模块怎么写？" class="headerlink" title="JS的模块（2） - 模块怎么写？"></a>JS的模块（2） - 模块怎么写？</h3><ul>
<li>变量odoo(在js文件里任何地方都可以访问!)<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 在file_a.js里</span></span><br><span class="line"> odoo.define(<span class="string">&#x27;my_module_a&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>)</span>&#123;</span><br><span class="line">     <span class="keyword">var</span> a = <span class="number">1</span>;</span><br><span class="line">     <span class="keyword">var</span> b = &#123;<span class="string">&#x27;a&#x27;</span>: <span class="number">10</span>, <span class="string">&#x27;b&#x27;</span>: <span class="number">20</span>&#125;;</span><br><span class="line"></span><br><span class="line">     <span class="keyword">return</span> &#123;<span class="string">&#x27;a&#x27;</span>: a, <span class="string">&#x27;b&#x27;</span>: b&#125;</span><br><span class="line"> &#125;)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 在file_b.js里</span></span><br><span class="line"> odoo.define(<span class="string">&#x27;my_module_b&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>)</span>&#123;</span><br><span class="line">    <span class="keyword">var</span> a = <span class="built_in">require</span>(<span class="string">&#x27;my_module_a&#x27;</span>).a;</span><br><span class="line">    <span class="keyword">var</span> b = <span class="built_in">require</span>(<span class="string">&#x27;my_module_a&#x27;</span>).b;</span><br><span class="line">    <span class="built_in">console</span>.log(a)</span><br><span class="line"> &#125;)</span><br></pre></td></tr></table></figure></li>
</ul>
<hr>
<h3 id="odoo组件的扩展"><a href="#odoo组件的扩展" class="headerlink" title="odoo组件的扩展"></a>odoo组件的扩展</h3><ul>
<li>就像odoo的模块都是继承自models.Model一样，js里的继承也无处不在！</li>
<li>extend方法</li>
<li>super关键字<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> Widget = <span class="built_in">require</span>(<span class="string">&#x27;web.Widget&#x27;</span>);     <span class="comment">// 这个组件是odoo系统提供的</span></span><br><span class="line"><span class="keyword">var</span> my_widget = Widget.extend(&#123;</span><br><span class="line">    <span class="attr">a</span>: <span class="number">1</span>,</span><br><span class="line">    <span class="attr">b</span>: <span class="number">2</span>,</span><br><span class="line">    <span class="attr">c</span>: <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">&quot;这是通过继承添加的方法！&quot;</span>)</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="attr">d</span>: <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">// do sth!</span></span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">this</span>._super.apply(<span class="built_in">this</span>, <span class="built_in">arguments</span>)</span><br><span class="line">    &#125;,</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure></li>
</ul>
<hr>
<h1 id="把模块和扩展rua起来！"><a href="#把模块和扩展rua起来！" class="headerlink" title="把模块和扩展rua起来！"></a>把模块和扩展rua起来！</h1><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">odoo.define(<span class="string">&#x27;my_module_c&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>)</span>&#123;</span><br><span class="line">   <span class="keyword">var</span> Widget = <span class="built_in">require</span>(<span class="string">&#x27;web.Widget&#x27;</span>);  </span><br><span class="line">   <span class="keyword">var</span> my_widget = Widget.extend(&#123;</span><br><span class="line">       <span class="attr">a</span>: <span class="number">1</span>,</span><br><span class="line">       <span class="attr">b</span>: <span class="number">2</span>,</span><br><span class="line">       <span class="attr">c</span>: <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">           <span class="built_in">console</span>.log(<span class="string">&quot;这是通过继承添加的方法！&quot;</span>)</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;)</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>


<hr>
<h1 id="再回顾下动作组件是怎么用的"><a href="#再回顾下动作组件是怎么用的" class="headerlink" title="再回顾下动作组件是怎么用的"></a>再回顾下动作组件是怎么用的</h1><ul>
<li>关键字<code>tag</code>！</li>
</ul>
<hr>
<h1 id="怎么将我们写的组件和tag关联起来？"><a href="#怎么将我们写的组件和tag关联起来？" class="headerlink" title="怎么将我们写的组件和tag关联起来？"></a>怎么将我们写的组件和tag关联起来？</h1><ul>
<li>动作组件的注册中心<code>action_registry</code><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">record</span> <span class="attr">id</span>=<span class="string">&quot;action1&quot;</span> <span class="attr">model</span>=<span class="string">&quot;ir.actions.client&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">&quot;name&quot;</span>&gt;</span>销售报表<span class="tag">&lt;/<span class="name">field</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">&quot;tag&quot;</span>&gt;</span>my_sale_report<span class="tag">&lt;/<span class="name">field</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">record</span>&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">odoo.define(<span class="string">&#x27;my_module_d&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>)</span>&#123;</span><br><span class="line">   <span class="keyword">var</span> Widget = <span class="built_in">require</span>(<span class="string">&#x27;web.Widget&#x27;</span>); </span><br><span class="line">   <span class="keyword">var</span> action_registry = <span class="built_in">require</span>(<span class="string">&#x27;web.core&#x27;</span>).action_registry; </span><br><span class="line">   <span class="keyword">var</span> my_widget = Widget.extend(&#123;&#125;);</span><br><span class="line">   action_registry.add(<span class="string">&#x27;my_sale_report&#x27;</span>, my_widget);</span><br><span class="line"></span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure></li>
</ul>
<hr>
<h1 id="我要的效果呢，我的内容呢？"><a href="#我要的效果呢，我的内容呢？" class="headerlink" title="我要的效果呢，我的内容呢？"></a>我要的效果呢，我的内容呢？</h1><ul>
<li>组件继承自<code>web.Widget</code>（extend、_rpc）</li>
<li>QWEB模板</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">t</span> <span class="attr">t-name</span>=<span class="string">&quot;my_report_template&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">table</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span> <span class="attr">t-foreach</span>=<span class="string">&quot;widget.table_data&quot;</span> <span class="attr">t-as</span>=<span class="string">&quot;row&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span> <span class="attr">t-foreach</span>=<span class="string">&quot;row&quot;</span> <span class="attr">t-as</span>=<span class="string">&quot;cell&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">t</span> <span class="attr">t-esc</span>=<span class="string">&quot;cell&quot;</span>/&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">t</span>&gt;</span></span><br></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">odoo.define(<span class="string">&#x27;my_module_e&#x27;</span>, <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>)</span>&#123;</span><br><span class="line">   <span class="keyword">var</span> Widget = <span class="built_in">require</span>(<span class="string">&#x27;web.Widget&#x27;</span>); </span><br><span class="line">   <span class="keyword">var</span> action_registry = <span class="built_in">require</span>(<span class="string">&#x27;web.core&#x27;</span>).action_registry; </span><br><span class="line">   <span class="keyword">var</span> my_widget = Widget.extend(&#123;</span><br><span class="line">       <span class="attr">template</span>: <span class="string">&#x27;my_report_template&#x27;</span>,</span><br><span class="line">       <span class="comment">// tagName: &#x27;div&#x27;,</span></span><br><span class="line">       <span class="comment">// className: null,</span></span><br><span class="line">       <span class="comment">// attributes: &#123;&#125;,</span></span><br><span class="line">       table_data = [[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>], [<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]],</span><br><span class="line">   &#125;);</span><br><span class="line">   action_registry.add(<span class="string">&#x27;my_sale_report&#x27;</span>, my_widget);</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>


<hr>
<h1 id="组件的生命周期"><a href="#组件的生命周期" class="headerlink" title="组件的生命周期"></a>组件的生命周期</h1><ul>
<li>init：组件初始化，类似__init__</li>
<li>willStart: 组件初始化之后，QWEB模板渲染之前，在这里和后台通信获取数据</li>
<li>渲染过程，没有确定的方法，系统自动进行渲染（$el、template、tagName）</li>
<li>start: QWEB渲染结束后调用此方法，可以对渲染结果进一步修改</li>
<li>挂载渲染结果到DOM</li>
<li>destroy: 组件被摧毁时调用方法，父级被销毁时，下级组件也会被销毁</li>
</ul>
<hr>
<h1 id="和后台的通信"><a href="#和后台的通信" class="headerlink" title="和后台的通信"></a>和后台的通信</h1><ul>
<li>_rpc</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">odoo.define(&#x27;my_module_e&#x27;, function(require)&#123;</span><br><span class="line">    var Widget = require(&#x27;web.Widget&#x27;); </span><br><span class="line">    var action_registry = require(&#x27;web.core&#x27;).action_registry; </span><br><span class="line">    var my_widget = Widget.extend(&#123;</span><br><span class="line">        template: &#x27;my_report_template&#x27;,</span><br><span class="line">        init: function()&#123;</span><br><span class="line">            this.table_data = []</span><br><span class="line">        &#125;,</span><br><span class="line"></span><br><span class="line">        willStart: function()&#123;</span><br><span class="line">            var self = this;</span><br><span class="line">            this._rpc(&#123;</span><br><span class="line">                model: &#x27;sale.order&#x27;,</span><br><span class="line">                method: &#x27;get_report_data&#x27;,</span><br><span class="line">                args: [&#x27;args&#x27;, &#x27;args2&#x27;],</span><br><span class="line">            &#125;).then(function(result)&#123;</span><br><span class="line">                self.table_data = result</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;);</span><br><span class="line">    action_registry.add(&#x27;my_sale_report&#x27;, my_widget);</span><br><span class="line"> &#125;)</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<hr>
<h1 id="最后一步！"><a href="#最后一步！" class="headerlink" title="最后一步！"></a>最后一步！</h1><ul>
<li><code>my_report_template</code>模板位于<code>my_module/static/xml/templates.xml</code></li>
<li><code>my_sale_report</code>动作组件位于<code>my_module/static/js/report_demo.js</code></li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- my_module/views/import_js.xml --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">template</span> <span class="attr">id</span>=<span class="string">&quot;import_test_js&quot;</span> <span class="attr">name</span>=<span class="string">&quot;演示demo&quot;</span> <span class="attr">inherit_id</span>=<span class="string">&quot;web.assets_backend&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">xpath</span> <span class="attr">expr</span>=<span class="string">&quot;.&quot;</span> <span class="attr">position</span>=<span class="string">&quot;inside&quot;</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- 此组件依赖的其他JS库 --&gt;</span></span><br><span class="line">        ...</span><br><span class="line">        <span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">&quot;text/javascript&quot;</span> <span class="attr">src</span>=<span class="string">&quot;/my_module/static/js/report_demo.js&quot;</span>/&gt;</span><span class="handlebars"><span class="xml"></span></span></span><br><span class="line"><span class="xml"><span class="handlebars">    <span class="tag">&lt;/<span class="name">xpath</span>&gt;</span></span></span></span><br><span class="line"><span class="xml"><span class="handlebars"><span class="tag">&lt;/<span class="name">template</span>&gt;</span></span></span></span><br></pre></td></tr></table></figure>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># my_module/__manifest__.py</span></span><br><span class="line">&#123;</span><br><span class="line">    ...</span><br><span class="line">    data: [<span class="string">&#x27;views/import_js.xml&#x27;</span>]</span><br><span class="line">    qweb: [<span class="string">&#x27;static/xml/templates.xml&#x27;</span>]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<hr>

    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>二扬
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://eryangz.gitee.io/20200618/odoo%E5%89%8D%E7%AB%AF%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91/" title="odoo前端组件开发">https://eryangz.gitee.io/20200618/odoo前端组件开发/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/js/" rel="tag"><i class="fa fa-tag"></i> js</a>
              <a href="/tags/odoo%E5%89%8D%E7%AB%AF/" rel="tag"><i class="fa fa-tag"></i> odoo前端</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/20200618/%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/" rel="prev" title="单例模式">
      <i class="fa fa-chevron-left"></i> 单例模式
    </a></div>
      <div class="post-nav-item">
    <a href="/20200718/pgsql%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E4%BD%BF%E7%94%A8/" rel="next" title="pgsql常用命令使用">
      pgsql常用命令使用 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89ODOO-JS%E7%BB%84%E4%BB%B6%EF%BC%88%E5%88%9D%E7%BA%A7%EF%BC%89"><span class="nav-text">自定义ODOO JS组件（初级）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFodoo-js%E7%BB%84%E4%BB%B6%EF%BC%9F"><span class="nav-text">什么是odoo js组件？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E7%9A%84%E5%88%86%E7%B1%BB%EF%BC%9A"><span class="nav-text">组件的分类：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8A%A8%E4%BD%9C%E7%BB%84%E4%BB%B6"><span class="nav-text">动作组件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%80%8E%E4%B9%88%E7%94%A8%EF%BC%9F"><span class="nav-text">怎么用？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E4%BA%9B%E7%B3%BB%E7%BB%9F%E5%B7%B2%E6%9C%89%E7%9A%84%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%8A%A8%E4%BD%9C"><span class="nav-text">一些系统已有的客户端动作</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%80%8E%E4%B9%88%E5%86%99%EF%BC%9F"><span class="nav-text">怎么写？</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%9C%80%E8%A6%81%E4%B8%80%E4%BA%9B%E5%9F%BA%E7%A1%80%E7%9A%84JS%E7%9F%A5%E8%AF%86"><span class="nav-text">需要一些基础的JS知识</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E4%BA%9B%E9%9C%80%E8%A6%81%E7%9F%A5%E9%81%93%E7%9A%84%E7%82%B9"><span class="nav-text">一些需要知道的点</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#JS%E7%9A%84%E6%A8%A1%E5%9D%97%EF%BC%881%EF%BC%89-%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E6%A8%A1%E5%9D%97%EF%BC%9F"><span class="nav-text">JS的模块（1） - 为什么需要模块？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#JS%E7%9A%84%E6%A8%A1%E5%9D%97%EF%BC%882%EF%BC%89-%E6%A8%A1%E5%9D%97%E6%80%8E%E4%B9%88%E5%86%99%EF%BC%9F"><span class="nav-text">JS的模块（2） - 模块怎么写？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#odoo%E7%BB%84%E4%BB%B6%E7%9A%84%E6%89%A9%E5%B1%95"><span class="nav-text">odoo组件的扩展</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8A%8A%E6%A8%A1%E5%9D%97%E5%92%8C%E6%89%A9%E5%B1%95rua%E8%B5%B7%E6%9D%A5%EF%BC%81"><span class="nav-text">把模块和扩展rua起来！</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%86%8D%E5%9B%9E%E9%A1%BE%E4%B8%8B%E5%8A%A8%E4%BD%9C%E7%BB%84%E4%BB%B6%E6%98%AF%E6%80%8E%E4%B9%88%E7%94%A8%E7%9A%84"><span class="nav-text">再回顾下动作组件是怎么用的</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%80%8E%E4%B9%88%E5%B0%86%E6%88%91%E4%BB%AC%E5%86%99%E7%9A%84%E7%BB%84%E4%BB%B6%E5%92%8Ctag%E5%85%B3%E8%81%94%E8%B5%B7%E6%9D%A5%EF%BC%9F"><span class="nav-text">怎么将我们写的组件和tag关联起来？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%88%91%E8%A6%81%E7%9A%84%E6%95%88%E6%9E%9C%E5%91%A2%EF%BC%8C%E6%88%91%E7%9A%84%E5%86%85%E5%AE%B9%E5%91%A2%EF%BC%9F"><span class="nav-text">我要的效果呢，我的内容呢？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%BB%84%E4%BB%B6%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F"><span class="nav-text">组件的生命周期</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%92%8C%E5%90%8E%E5%8F%B0%E7%9A%84%E9%80%9A%E4%BF%A1"><span class="nav-text">和后台的通信</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%9C%80%E5%90%8E%E4%B8%80%E6%AD%A5%EF%BC%81"><span class="nav-text">最后一步！</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="二扬"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">二扬</p>
  <div class="site-description" itemprop="description">念念不忘, 必有回响</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">26</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/EryangZzz" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;EryangZzz" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;" rel="noopener" target="_blank"><i class="fa fa-fw fa-github-alt"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="/1289256052" title="QQ → 1289256052"><i class="fa fa-fw fa-qq"></i>QQ</a>
      </span>
      <span class="links-of-author-item">
        <a href="/1289256052@qq.com" title="E-Mail → 1289256052@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



<script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
<div class="widget-wrap">
    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=110 src="//music.163.com/outchain/player?type=0&id=8435349308&auto=1&height=66"></iframe>
    <h3 class="widget-title">标签云</h3>
    <div id="myCanvasContainer" class="widget tagcloud">
        <canvas width="250" height="250" id="resCanvas" style="width=100%">
            <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/emqx/" rel="tag">emqx</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flask/" rel="tag">flask</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/js/" rel="tag">js</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/metaclass/" rel="tag">metaclass</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/" rel="tag">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo/" rel="tag">odoo</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo%E5%89%8D%E7%AB%AF/" rel="tag">odoo前端</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo%E9%83%A8%E7%BD%B2/" rel="tag">odoo部署</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/office%E9%A2%84%E8%A7%88/" rel="tag">office预览</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pgsql/" rel="tag">pgsql</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pip%E6%BA%90/" rel="tag">pip源</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pyinstaller/" rel="tag">pyinstaller</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/re/" rel="tag">re</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rtsp/" rel="tag">rtsp</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time%E6%A8%A1%E5%9D%97/" rel="tag">time模块</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu/" rel="tag">ubuntu</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu%E6%BA%90/" rel="tag">ubuntu源</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%85%83%E7%B1%BB/" rel="tag">元类</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" rel="tag">多线程</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9C%8D%E5%8A%A1%E9%85%8D%E7%BD%AE/" rel="tag">服务配置</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" rel="tag">正则表达式</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%AC%91%E8%84%B8%E4%BA%A4%E4%BA%92/" rel="tag">笑脸交互</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%A7%86%E9%A2%91%E6%B5%81/" rel="tag">视频流</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" rel="tag">设计模式</a><span class="tag-list-count">1</span></li></ul>
        </canvas>
    </div>
</div>




      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">二扬</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">105k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">1:35</span>
</div>



        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
 var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>





  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
